package com.example.zhaoping.serviceImpl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.zhaoping.entity.Enterprise;
import com.example.zhaoping.mapper.EnterpriseMapper;
import com.example.zhaoping.service.EnterpriseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class EnterpriseServiceImpl implements EnterpriseService {
    @Resource
    private EnterpriseMapper enterpriseMapper;

    @Override
    public int inster(Enterprise enterprise) {
        return enterpriseMapper.insert(enterprise);
    }

    @Override
    public boolean delect(Long id) {
        return false;
    }

    @Override
    public Enterprise eitd(Enterprise enterprise) {
        return null;
    }

    @Override
    public Enterprise selectOne(String username) {
        QueryWrapper<Enterprise> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("username",username);
        return enterpriseMapper.selectOne(queryWrapper1);
    }

    @Override
    public Enterprise selectById(int id) {
        return enterpriseMapper.selectById(id);
    }

    @Override
    public Enterprise login(Enterprise entity) {
        QueryWrapper<Enterprise> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("username",entity.getUsername())
                .eq("password",entity.getPassword());
        return enterpriseMapper.selectOne(queryWrapper1);
    }

    @Override
    public Enterprise selectByName(String name) {
        QueryWrapper<Enterprise> queryWrapper1 = new QueryWrapper<>();
        queryWrapper1.eq("name",name);
        return enterpriseMapper.selectOne(queryWrapper1);
    }

}
